package com.dwxt.sport.business.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.sport.business.entity.VideoSurveillance;
import com.dwxt.sport.business.service.VideoSurveillanceService;
import com.dwxt.sport.business.vo.videoSurveillance.InsertOrUpdateVideoSurveillanceVo;
import com.dwxt.sport.business.vo.videoSurveillance.SelectVideoSurveillanceVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 视频监控 Controller
 *
 * @author Kuang.JiaZhuo
 * @date 2020-07-27 11:18
 */
@RestController
@RequestMapping("/videoSurveillance")
@Api(tags={"视频监控相关接口"})
public class VideoSurveillanceController {

    @Resource
    VideoSurveillanceService videoSurveillanceService;

    @ApiOperation(value = "新增视频监控", notes = "新增视频监控", response = Integer.class)
    @PostMapping("/back/insertVideoSurveillance")
    public BaseResult insertVideoSurveillance(InsertOrUpdateVideoSurveillanceVo insertVo){
        int result = this.videoSurveillanceService.insertVideoSurveillance(insertVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "更新视频监控", notes = "更新视频监控", response = Integer.class)
    @PostMapping("/back/updateVideoSurveillance")
    public BaseResult updateVideoSurveillance(InsertOrUpdateVideoSurveillanceVo updateVo){
        int result = this.videoSurveillanceService.updateVideoSurveillance(updateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "获取视频监控列表", notes = "获取视频监控列表(带分页)", response = VideoSurveillance.class)
    @PostMapping("/back/getVideoSurveillanceByPage")
    public BaseResult getVideoSurveillanceByPage(SelectVideoSurveillanceVo selectVo){
        PageInfo<VideoSurveillance> pageInfo = this.videoSurveillanceService.getVideoSurveillanceByPage(selectVo);
        return BaseResult.ok(pageInfo);
    }

    @ApiOperation(value = "视频监控详情", notes = "根据id查询视频监控详情", response= VideoSurveillance.class)
    @PostMapping(value = "/back/getVideoSurveillanceById")
    public BaseResult getVideoSurveillanceById(@ApiParam(value = "视频监控id", required = true) @RequestParam String id){
        VideoSurveillance videoSurveillance = this.videoSurveillanceService.getVideoSurveillanceById(id);
        return BaseResult.ok(videoSurveillance);
    }

    @ApiOperation(value = "删除视频监控", notes = "根据ids批量删除视频监控", response= Integer.class)
    @PostMapping(value = "/back/deleteVideoSurveillanceByIds")
    public BaseResult deleteVideoSurveillanceByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.videoSurveillanceService.deleteVideoSurveillanceByIds(ids);
        return BaseResult.ok(result);
    }
}
